import React, { useState, useEffect } from 'react'
import { View, Image,Button } from '@tarojs/components'
import { AtList, AtListItem, AtButton, AtToast } from "taro-ui"
import Taro from '@tarojs/taro'

import useModel from 'flooks';
import store from '../../../stores/index'

import './index.less'
import "taro-ui/dist/style/components/list.scss";


export default (props: any) => {
  const {title}=  props.data
  const {uBusinessId} = props
  const { detailDataChange } = useModel(store.detailData, ['detailData'])
  const toPage = (path:any)=>{
    Taro.switchTab({
      url:path
    })
  }
  const onShareAppMessage = (res:any)=> {
    if (res.from === 'button') {
      // 来自页面内转发按钮
      console.log(res.target)
    }
    return {
      title: `u选商家 ${title}`,
      path: `/pages/uBusinessDetail/index?uBusinessId=${uBusinessId}`
    }
  }
  const toOlder = (i:any)=>{
    detailDataChange(props.data)
    Taro.navigateTo({
      url:`/pages/uBuy/index?ids=0`
    })
  }
  return (
    <View className='footer'>
      <View className='footerL'>
        <View className='ico' onClick={()=>{toPage('/pages/index/index')}}>
          <Image className='img' src={IMGSRC+'usy.png'}></Image>
          <View className='txt'>首页</View>
        </View>
        <View className='ico ico2'>
          <Button className='shareBtn' openType='share' onClick={onShareAppMessage}   type='primary'>
            <Image className='img' src={IMGSRC+'ufx.png'}></Image>
          </Button>
          <View className='txt'>分享</View>
        </View>
        <View className='ico' onClick={()=>{toPage('/pages/my/index')}}>
          <Image className='img' src={IMGSRC+'uwd.png'}></Image>
          <View className='txt'>我的</View>
        </View>
      </View>
      <View className='footerR'>
        <AtButton disabled={!props.data.ticket.filter((item:any)=>item.numTotal>item.num).length} onClick={toOlder} className='getBtn' size='small'>立即抢购</AtButton>
      </View>
    </View>
  )
}
